package git.soulbgm.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import git.soulbgm.common.annotation.ElasticJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component("jobDemo")
@Slf4j
@ElasticJob(jobName = "soul",
        cron = "0/10 * * * * ?",
        jobEventRdb = true,
        //jobListener = "elasticJobListener",
        shardingItemParameters = "0=A,1=B,2=C",
        shardingTotalCount = 3,
        jobParameter = "abcd",
        description = "任务Demo")
public class JobDemo implements SimpleJob {

    @Override
    public void execute(ShardingContext context) {
        log.info("分片总数:{},分片项:{},线程id:{},分片参数:{}",
                context.getShardingTotalCount(),
                context.getShardingItem(),
                Thread.currentThread().getId(),
                context.getShardingParameter());
    }
}
